package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.ShangpinDao;
import daoImpl.ShangpinDaoImpl;
import entlty.Shangpin;

/**
 * Servlet implementation class Sousuo
 */
@WebServlet("/Sousuo")
public class Sousuo extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("GBK");
		String sousuo=req.getParameter("sousuo");
		Shangpin s=new Shangpin();
		if(sousuo!=null&&!sousuo.equals("")){
			s.setSname(sousuo);
		}
		ShangpinDao sdao=new ShangpinDaoImpl();
		List<Shangpin> sp=sdao.getAll(s);
		req.setAttribute("spp", sp);
		req.getRequestDispatcher("/Sousuo.jsp").forward(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
	

}
